﻿'Imports System.Data
'Imports System.Configuration
'Imports System.Web
'Imports System.Web.Security
'Imports System.Web.UI
'Imports System.Web.UI.WebControls
'Imports System.Web.UI.WebControls.WebParts
'Imports System.Web.UI.HtmlControls

Namespace App_code

    Public Class BasePage
        Inherits System.Web.UI.Page

        Protected Overrides Sub OnPreInit(ByVal e As System.EventArgs)

            MyBase.OnPreInit(e)

            If Session("MyTheme") Is System.dbnull.value Then
                Session.Add("MyTheme", "Fwrk")
                Page.Theme = Session("MyTheme").ToString
            Else
                Page.Theme = Session("MyTheme").ToString
            End If

        End Sub
    End Class

    'Scripting JS generado desde el code behing
    Public Class JavaScript
        'Private Sub test()
        '    'Ejemplo de uso:
        '    Dim mJavaScript As JavaScript = New JavaScript()
        '    mJavaScript.Message("Datos incompletos.", Page.Request.Browser, Page.ClientScript, this.GetType())
        'End Sub

        ''Coloca el foco en un determinado control (por ID)
        'Public Sub SetFocus(ByVal pCtrl As Control, ByVal pBrowser As HttpBrowserCapabilities, _
        '                     ByVal pPageClientScript As System.Web.UI.ClientScriptManager, ByVal pPageType As System.Type)

        '    If pBrowser.EcmaScriptVersion.Major > 0 Then
        '        Dim mScript As String = "<script language='javascript'>document.getElementById('" + pCtrl.ClientID.ToString() + "').focus();</script>"
        '        Dim mJavaScript As JavaScript = New JavaScript()
        '        mJavaScript.Register(pPageClientScript, pPageType, "SetFocus", mScript)
        '    End If

        'End Sub

        ''Despliega un mensaje al usuario
        'Public Sub Message(ByVal pText As String, ByVal pBrowser As HttpBrowserCapabilities, _
        '                   ByVal pPageClientScript As System.Web.UI.ClientScriptManager, ByVal pPageType As System.Type)

        '    If pBrowser.EcmaScriptVersion.Major > 0 Then
        '        Dim mScript As String = "<script language='javascript'>alert('" + pText + "');</script>"
        '        Dim mJavaScript As JavaScript = New JavaScript()
        '        mJavaScript.Register(pPageClientScript, pPageType, "Message", mScript)
        '    End If

        'End Sub

        ''Registra un script
        'Public Sub Register(ByVal pPageClientScript As System.Web.UI.ClientScriptManager, ByVal pPageType As System.Type, _
        '                    ByVal pKey As String, ByVal pScript As String)

        '    Dim mClientScript As ClientScriptManager = pPageClientScript
        '    If Not mClientScript.IsStartupScriptRegistered(pKey) Then
        'mClientScript.RegisterStartupScript(pPageType.GetType(), pKey, pScript, false);
        '    End If

        'End Sub

    End Class

End Namespace

